<style>
    .add-msg .add-forma{
        float: left;
    }
    .add-forma .add-ipt button {
        float: right;
    }
</style>
<include file="common:__head__"/>
<div class="permissions-tabs">
    <a class="role tabs-bg" href="{:U('Order/index')}">全部</a>
</div>
<div class="permissions-content">
    <div class="permissions-le">
    <form method="get" action="">
        <div class="add-msg">
            <div class="add-form add-forma">
                <input type="hidden" name="m" value="seller"/>
                <input type="hidden" name="c" value="order"/>
                <input type="hidden" name="a" value="index"/>
                <input name="user_name" placeholder="收货人用户名或手机" type="text" class="search-ipt" value="{$u_name}"/>
                <input name="user_phone" placeholder="下单人用户名" type="text" class="search-ipt" value="{$u_phone}"/>
                <input name="start_time" id="start_time" readonly placeholder="下单开始时间" type="text" class="search-ipt" value="{$start_time}"/>
                <input name="end_time" id="end_time" readonly placeholder="下单结束时间" type="text" class="search-ipt" value="{$end_time}"/>

                <select name="is_pay" id="is_pay" >
                    <option value="-2">支付状态</option>
                    <foreach name="pay_status" item="pay" key="k">
                        <if condition="$k eq $x_pay">
                            <option value="{$k}" selected="selected">{$pay}</option>
                            <else />
                            <option value="{$k}">{$pay}</option>
                        </if>
                    </foreach>
                </select>

                <select name="status" id="is_pay" >
                    <option value="-2">订单状态</option>
                        <foreach name="order_status" item="status" key="k">
                            <if condition="$k eq $x_status">
                                <option value="{$k}" selected="selected">{$status}</option>
                                <else />
                                <option value="{$k}">{$status}</option>
                            </if>
                        </foreach>
                </select>

                <select name="is_deliver" id="is_pay" >
                    <option value="-2">发货状态</option>
                    <foreach name="deliver_status" item="deliver" key="k">
                        <if condition="$k eq $x_deliver">
                            <option value="{$k}" selected="selected">{$deliver}</option>
                            <else />
                            <option value="{$k}">{$deliver}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="add-msg">
            <div class="add-form add-forma">
                <div class="add-ipt">
                    <input placeholder="订单编号..." type="text" name="order_id" class="add-name" value="{$orderId}">
                    <button name="btn"value="1"></button>
                </div>
            </div>
        </div>
    </form>

        <div class="permissions-table">
            <table border="0" width="100%">
                <thead>
                <tr>
                    <td width="15%">订单编号</td>
                    <td>下单人</td>
                    <td>收货人</td>
                    <td>总金额</td>
                    <td>支付状态</td>
                    <td>发货状态</td>
                    <td>订单状态</td>
                    <td>运费</td>
                    <td>下单时间</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody>
                <volist name="orders" id="order" key="k">
                    <tr>
                        <td>{$order['order_id']}</td>
                        <td>{$order['agent_name']}</td>
                        <td>{$order['consignee']}: {$order['phone']}</td>
                        <td>{$order['price']}</td>
                        <td>
                            <if condition="$order['is_pay'] eq -1">
                                未付款
                            <else />
                               <span style="color: green;">已付款</span>
                            </if>
                        </td>
                        <td>
                            <if condition="$order['is_deliver'] eq -1">
                                <if condition="($order['is_pay'] eq 1 AND $order['is_top'] eq 1) OR ($order['is_pay'] eq 1 AND $order['is_platform'] eq 1) OR ($order['is_pay'] eq 1 AND $order['is_no_agent'] eq 1)">
                                    <span style="color: red;">待平台发货</span>
                                    <elseif condition="$order['is_agree'] neq -1"/>
                                    <span style="color: #ccc;">未发货</span>
                                    <elseif condition="$order['is_agree'] eq -1"/>
                                    <span style="color: firebrick;">未发货(董事不通过)</span>
                                </if>
                                <else />
                                <span style="color: green">已发货</span>
                            </if>
                        </td>
                        <td>
                            <switch name="order['status']">
                                <case value="-1">
                                    <span style="color: red;">已取消</span>
                                </case>
                                <case value="1">
                                    <span style="color: #9c9c9c">待确认</span>
                                </case>
                                <case value="2">
                                    <span style="color: #ff5900;">退款中</span>
                                </case>
                                <case value="3">
                                    <span style="color: green;">交易成功</span>
                                </case>
                                <default />
                                <span style="color:blue;">进行中</span>
                            </switch>
                        </td>
                        <td>{$order['freight_price']}元</td>
                        <td>{$order['time']|date="Y-m-d H:i:s",###}</td>
                        <td>
                            <a href="{:U('Order/detail', array('id'=> $order['id']))}" class="btn btn-blue">查看</a>
                            <if condition="$order['is_pay'] eq -1 AND $order['status'] neq -1">
                                <a href="{:U('Order/edit', array('id'=>$order['id']))}" class="btn btn-green">编辑</a>
                            </if>

                            <if condition="$order['status'] eq -1">
                                <a class="btn btn-red del" href="javascript:;" data-id="{$order['id']}">删除</a>
                            </if>

                            <if condition="$order['is_platform'] eq 1 AND $order['status'] eq 0 AND $order['deliver_time'] eq 0 AND $order['is_pay'] eq 1">
                                 <a class="btn btn-red" href="{:U('Order/invoice', array('id'=>$order['id']))}" >去发货</a>
                            </if>
                        </td>
                    </tr>
                </volist>
                </tbody>
            </table>
            {$page}
        </div>
    </div>
    <div class="permissions-ri">
        <a href="" class="permissions-help">帮助和服务</a>
        {:W('Help/get_help_module',array('code' => 'order'))}
    </div>
</div>
<script src="__PUBLIC__/plugins/layer/laydate/laydate.js"></script>
<include file="common:__foot__"/>
<script type="text/javascript">
    $(function() {
        //日历插件
        $('#start_time').layDate();
        $('#end_time').layDate();

        //删除订单
        $('.del').click(function() {
            var id = $(this).attr('data-id');
            layer.confirm('您确认删除此订单吗?删除后没法恢复', {
              btn: ['确认','取消']
            }, function(){
                $.ajax({
                    url: "{:U('Order/del')}",
                    type: 'post',
                    data: {
                        id: id,
                    },
                    success: function() {
                        window.location.reload();
                    }
                });
            });
        });

    });
</script>